﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Web;
using StudentWeb.DAL;
using StudentWeb.Model;
using StudentWeb.Common;

namespace StudentWeb.BLL
{
    public class ReviewsBO
    {
        #region 评论信息 全部记录
        public IResult GetReviewsList()
        {
            var list = new ReviewsDataDAO().GetList();
            return new DataResult(list);
        }
        #endregion
        #region 评论信息 添加
        public bool InsertReviewsInfo(dynamic data)
        {
            var user = new ReviewsData()
            {
                TouristID = data.TouristID,
                ReviewContent = data.ReviewContent,
                ReviewDate = data.ReviewDate,
                Rating = data.Rating
            };
            var result = new ReviewsDataDAO().Insert(user);
            return result > 0;
        }
        #endregion
        #region 评论信息 修改
        public bool UpdateReviewsInfo(dynamic data)
        {
            int ReviewID = data.ReviewID;
            var record = new ReviewsDataDAO().GetInfo(ReviewID);
            record.TouristID = data.TouristID;
            record.ReviewContent = data.ReviewContent;
            record.ReviewDate = data.ReviewDate;
            record.Rating = data.Rating;
            var result = new ReviewsDataDAO().Update(record);
            return result > 0;
        }
        #endregion
        #region 评论信息 删除
        public IResult DeleteReviewsInfo(int ReviewID)
        {
            var res = new ReviewsDataDAO().Delete(ReviewID);
            if (res > 0)
            {
                return new Result(ResultCode.Success, "删除成功");
            }
            else
            {
                return new Result(ResultCode.Fail, "删除失败");
            }
        }
        #endregion
    }
}
